/**Resilience4j+Eureka+Feign
 * 1）依赖库：SpringCloud版本为2020.0.0及以上，核心依赖为resilience4j-feign
 * 2) main上@EnableFeignClients注解之
 * 3）Interface上@FeignClient注解之，并启用configuration属性定义配置文件
 * 4）在配置文件中用FeignDecorators引入fallback和interceptor
 * 5）定义降级类FeignFallBack,其必须实现@FeignClient注解的Interface，其接口方法的实现即为降级方法
 * 6）定义拦截器（可选），implements RequestInterceptor
 */
package com.example.demoresilience4jfeignconsumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.Map;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class DemoResilience4jFeignConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoResilience4jFeignConsumerApplication.class, args);
    }

    @FeignClient(name="userlogin" , configuration = Resilience4jFeignConfiguration.class)
    public interface UserloginService{
        @RequestMapping(value = "/login",method = RequestMethod.GET)
        Map myUserlogin();
    }
}
